__author__ = 'Vincent Liu'

import NetValueLoader
import util
import sys

def WriteFuture(output_path,date,prod,nv_path):
	fd = open(output_path + "\\" + date + ".holding.csv",'w')
	fd.write("#tk,shr,lastGoodCls\n")
	nv = NetValueLoader.nvValue(date,prod,nv_path)
	nv.Load_FutureInfo()
	ft = nv.GetFutureTable()
	for k in ft:
		fd.write("%s,%d,%f\n" % (k[0],k[1],k[4]))
	fd.close()

if __name__ == "__main__":
	args= util.extract_opt(sys.argv)
	print(args)
	nv_path = args['disk'] + ":\\data\\WindDB\\production"+args['prod']+"\\netValue\\"
	WriteFuture(args['output'],args['start'],args['prod'],nv_path)
